{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "20ac7907",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "helloWorld!\n"
     ]
    }
   ],
   "source": [
    "print(\"helloWorld!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9eb14bc9",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a74fdbf8",
   "metadata": {},
   "outputs": [],
   "source": [
    "b = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4bec7aa5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "source": [
    "print(a+b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "374d9dbc",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "8b2762b7",
   "metadata": {},
   "outputs": [],
   "source": [
    "nd1 = np.array([[1,2,3],[4,5,6]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "bc545fa6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1 2 3]\n",
      " [4 5 6]]\n"
     ]
    }
   ],
   "source": [
    "print(nd1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "751341eb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd1.max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "c80d8d8b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd1.min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "5b9cc965",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.5"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd1.mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "47435913",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'numpy.ndarray'>\n"
     ]
    }
   ],
   "source": [
    "print(type(nd1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "9b2077ee",
   "metadata": {},
   "outputs": [],
   "source": [
    "nd2 = np.array([\"1\",\"2\",\"3\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "df2e8070",
   "metadata": {},
   "outputs": [],
   "source": [
    "nd2 = nd2.astype(\"int\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "5a8c3295",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 2 3]\n"
     ]
    }
   ],
   "source": [
    "print(nd2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "db099c68",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2, 3])"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd2[1:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "08218ba7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd2.max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "4e9ac545",
   "metadata": {},
   "outputs": [],
   "source": [
    "nd3 = np.array([[0,1,2,3,4,5],[10,11,12,13,14,15],[20,21,22,23,24,25],[30,31,32,33,34,35],[40,41,42,43,44,45],[50,51,52,53,54,55]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "39dfc8c1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0  1  2  3  4  5]\n",
      " [10 11 12 13 14 15]\n",
      " [20 21 22 23 24 25]\n",
      " [30 31 32 33 34 35]\n",
      " [40 41 42 43 44 45]\n",
      " [50 51 52 53 54 55]]\n"
     ]
    }
   ],
   "source": [
    "print(nd3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "e5725480",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([3, 4])"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# nd3[行的索引,列的索引]\n",
    "# nd3[起始行:结束行:步长,起始列:结束列:步长]\n",
    "nd3[0,3:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "c418fb5d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[44, 45],\n",
       "       [54, 55]])"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3[4:6,4:6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "667eb6cd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 2, 12, 22, 32, 42, 52])"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3[0:6,2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "bedcf3a6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[20, 22, 24],\n",
       "       [40, 42, 44]])"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3[2::2,0::2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "a14ad695",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 1, 12, 23, 34, 45])"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3[(0,1,2,3,4),(1,2,3,4,5)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "757bdab4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0  1  2  3  4  5]\n",
      " [10 11 12 13 14 15]\n",
      " [20 21 22 23 24 25]\n",
      " [30 31 32 33 34 35]\n",
      " [40 41 42 43 44 45]\n",
      " [50 51 52 53 54 55]]\n"
     ]
    }
   ],
   "source": [
    "print(nd3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "5dc72dc4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([31, 32, 33, 34, 35, 40, 41, 42, 43, 44, 45, 50, 51, 52, 53, 54, 55])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nd3[nd3>30]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "e3ae99bc",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = np.array([[4,5,6],[7,8,9]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "a88f1dbf",
   "metadata": {},
   "outputs": [],
   "source": [
    "b = np.array([[2,3,4],[5,6,7]])\n",
    "c = np.array([[1,2],[3,4],[5,6]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "81ac015e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[4 5 6]\n",
      " [7 8 9]]\n"
     ]
    }
   ],
   "source": [
    "print(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "1ec65f92",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[2 3 4]\n",
      " [5 6 7]]\n"
     ]
    }
   ],
   "source": [
    "print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "45d15321",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 6  8 10]\n",
      " [12 14 16]]\n",
      "[[2 2 2]\n",
      " [2 2 2]]\n",
      "[[ 8 15 24]\n",
      " [35 48 63]]\n",
      "[[2.         1.66666667 1.5       ]\n",
      " [1.4        1.33333333 1.28571429]]\n"
     ]
    }
   ],
   "source": [
    "# 矩阵的 \"加减乘除\"\n",
    "print(a+b)\n",
    "print(a-b)\n",
    "print(a*b)\n",
    "print(a/b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "a9a9456b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 6.86666667,  4.25      ],\n",
       "       [11.46666667,  7.        ]])"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.dot(a,1/c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c389b9c3",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
